/**
 * @ClassName SequentialRelationship
 * @Description TODO
 * @Author Quentin_zyj
 * @Date 2021/11/2 15:45
 */
public class SequentialRelationship {

    public static int relationship(int n) {
        int[] A = new int[n];
        A[0] = 1;
        for (int i = 1; i <= n - 1; i++) {
            A[i] = 0;
        }
        for (int i = 2; i <= n; i++) {
            for (int j = i - 1; j >= 1; j--) {
                A[j] = (j + 1) * (A[j - 1] + A[j]);
            }
        }
        int result = 0;
        for (int i = 0; i <= n - 1; i++) {
            result += A[i];
        }
        return result;
    }
}
